using System;
using UnityEngine;

public abstract class MonoSingleton<T> : MonoBehaviour where T : MonoSingleton<T>
{
    private static T mInstance = null;

    public static T Instance
    {
        get
        {
            if (mInstance == null)
            {
                mInstance = GameObject.FindObjectOfType(typeof(T)) as T;
            }
            return mInstance;
        }
    }
    
    private void Awake()
    {
        if (mInstance == null)
        {
            mInstance = this as T;
        }
    }

}